package cn.loioi.multi.service.user;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONArray;

import cn.loioi.multi.common.BaseService;
import cn.loioi.multi.mysql.model.SysUser;

public interface SysUserService extends BaseService<SysUser> {

	/**
	 * 根据账号更新内容
	 * @param record
	 * @return
	 */
	@Transactional(rollbackFor = { Exception.class, RuntimeException.class })
	public int updateByAccount(SysUser record);

	/**
	 * 修改密码
	 * @param account
	 * @param password
	 * @param password_again
	 * @return
	 */
	@Transactional(rollbackFor = { Exception.class, RuntimeException.class })
	public int changPassword(String account, String password, String password_again);

	/**
	 * 查询该用户的角色
	 * @param account
	 * @return
	 */
	public List<Map<String, Object>> selectUserRole(String account);

	/**
	 * 插入对应用户的角色
	 * @param account
	 * @param ids 角色ID
	 * @return
	 */
	@Transactional(rollbackFor = { Exception.class, RuntimeException.class })
	public int insertRoleResource(String account, JSONArray ids);

	/**
	 * 根据名字模糊查找用户
	 * @param name
	 * @return
	 */
	public List<SysUser> selectByName(String name);

}
